//
//  UPAddressPickerView.h
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/27.
//

#import <UIKit/UIKit.h>
#import "ADRLapidantModel.h"

NS_ASSUME_NONNULL_BEGIN

@class UPAddressPickerView;
@class UPDataItem;

@protocol UPAddressPickerDelegate <NSObject>

@optional
- (void)addressPicker:(UPAddressPickerView *)picker didSelectItem:(UPDataItem *)item atLevel:(NSInteger)level;
- (void)addressPicker:(UPAddressPickerView *)picker didCompleteSelection:(NSArray<UPDataItem *> *)path;
- (void)addressPicker:(UPAddressPickerView *)picker didClickConfirmButton:(NSArray<UPDataItem *> *)path;

@end

@interface UPDataItem : NSObject

@property (nonatomic, copy) NSString *itemId;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSArray<UPDataItem *> *children;
@property (nonatomic, assign, readonly) BOOL isLeaf;

- (instancetype)initWithId:(NSString *)itemId name:(NSString *)name children:(NSArray<UPDataItem *> * _Nullable)children;

@end

@interface UPAddressPickerView : UIView

@property (nonatomic, weak) id<UPAddressPickerDelegate> delegate;
@property (nonatomic, assign) NSInteger maxLevel;

- (void)loadCountryAddress:(ADRLapidantModel *)address;
- (void)resetSelection;
- (NSArray<UPDataItem *> *)getSelectedPath;

@end

NS_ASSUME_NONNULL_END
